package com.king01.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.king01.dao.RoleDao;
import com.king01.entity.Log;
import com.king01.entity.Role;
import com.king01.service.RoleService;
import com.king01.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author：张梓康
 * @date：Created in 2023/10/9 12:11
 * @description：
 * @modified By：
 * @version:
 */
@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleDao roleDao;

    @Override
    public Result findAllRole(Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage,pageSize);
        List<Role> roles = roleDao.selectAllRole();
        PageInfo<Role> pageInfo = new PageInfo<>(roles);
        return new Result(200,"获取分页成功",pageInfo);
    }

    @Override
    public Integer addRole(Role role) {
        Integer integer = roleDao.addRole(role);
        return integer;
    }

    @Override
    public Integer deleteRole(Integer roleid) {
        Integer integer = roleDao.deleteRole(roleid);
        return integer;
    }

    @Override
    public Integer updateRole(Role role) {
        Integer integer = roleDao.updateRole(role);
        return integer;
    }

    @Override
    public Result findAllLog(Integer currentPage, Integer pageSize) {
        PageHelper.startPage(currentPage,pageSize);
        List<Log> logs = roleDao.selectAllLog();
        PageInfo<Log> pageInfo = new PageInfo<>(logs);
        return new Result(200,"分页成功",pageInfo);
    }
}
    